<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<SCRIPT LANGUAGE="JavaScript">
<!--
	if(window.top.$("#current_pos").data('clicknum')==1 || window.top.$("#current_pos").data('clicknum')==null) {
	parent.document.getElementById('display_center_id').style.display='';
	parent.document.getElementById('center_frame').src = '?m=content&c=content&a=public_categorys&type=add&menuid=<?php echo $_GET['menuid'];?>&pc_hash=<?php echo $_SESSION['pc_hash'];?>';
	window.top.$("#current_pos").data('clicknum',0);
}
//-->
</SCRIPT>
<!-- <h3 style="padding-left: 20px;padding-top: 10px">
	<?=$data['catname']?>——人才
	<a href="?m=admin&c=category&a=init&module=admin" style="font-size:14px;color: #0000FF"><em>返回上一级</em></a>
</h3> -->

<div class="subnav">
	<div class="content-menu ib-a blue line-x">
		<a href="?m=admin&c=resources&a=init&catid=<?=$catid?>" ><em>全部</em></a>
		<span>|</span>
		<a href="?m=admin&c=resources&a=index&source_type=1&catid=<?=$catid?>" ><em>资讯</em></a>
		<span>|</span>
		<a href="?m=admin&c=resources&a=index&source_type=2&catid=<?=$catid?>" ><em>视频</em></a>
		<span>|</span>
		<a href="?m=admin&c=resources&a=index&source_type=3&catid=<?=$catid?>" ><em>图集</em></a>
		<span>|</span>
		<a href="?m=admin&c=resources&a=tIndex&catid=<?=$catid?>" class="on"><em>人才</em></a>
		<span>|</span>
		<a href="?m=admin&c=resources&a=cIndex&catid=<?=$catid?>" ><em>课程</em></a>
		<span>|</span>
		<a href="javascript:;" onclick="refreshDataCate(<?=$catid?>);"><em>刷新数据</em></a>

	</div>
</div>

<div class="pad-lr-10">

	<div id="searchid" style="">
		<form name="searchform" action="" method="get" >
			<input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
			<input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
			<input type="hidden" value="<?php echo ROUTE_A;?>" name="a">
			<input type="hidden" value="<?php echo $source_type;?>" name="source_type">
			<input type="hidden" value="1" name="search">
			<input type="hidden" value="<?=$catid?>" name="catid">
			<input type="hidden" value="<?php echo $pc_hash;?>" name="pc_hash">
			<table width="100%" cellspacing="0" class="search-form">
				<tbody>
				<tr>
					<td>

						<button type="button" style="float:right;margin-right:20px;margin-top:10px;" onclick="showAdd()" ><em>添加人才</em></button>
						<button type="button" style="float:right;margin-right:20px;margin-top:10px;" onclick="showSelect()" ><em>选择人才</em></button>
						<span style="clear: both"></span>
						<script>
							function showAdd(){
								window.top.art.dialog({
										id: 'add',
										iframe: '?m=information&c=talent&a=add&catid=<?=$catid?>',
										title: '添加人才',
										width: '900',
										height: '500',
										lock: true
									},
									function() {
										var d = window.top.art.dialog({
											id: 'add'
										}).data.iframe;
										var form = d.document.getElementById('dosubmit');
										form.click();
										return false;
									},
									function() {
										window.top.art.dialog({
											id: 'add'
										}).close()
									});
							}

							function edit(id, name){
								window.top.art.dialog({
										id: 'edit',
										iframe: '?m=information&c=talent&a=edit&catid=<?=$catid?>&id='+id,
										title: '修改'+name,
										width: '900',
										height: '500',
										lock: true
									},
									function() {
										var d = window.top.art.dialog({
											id: 'edit'
										}).data.iframe;
										var form = d.document.getElementById('dosubmit');
										form.click();
										return false;
									},
									function() {
										window.top.art.dialog({
											id: 'edit'
										}).close()
									});
							}
							function  showSelect(){
								window.top.art.dialog({
										id: 'select',
										iframe: '?m=information&c=talent&a=bindTalent&catid=<?=$catid?>',
										title: '选择人才',
										width: '1000',
										height: '500',
										lock: true
									},
									function() {
										var d = window.top.art.dialog({
											id: 'select'
										}).data.iframe;
										var relation = d.document.getElementById('relation');


										if(relation.value!=""){
											$.ajax({
												type:"get",
												url:"?m=information&c=talent&a=bindContestAjax&catid=<?=$catid?>&relation="+relation.value+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
												dataType: "json",
												success:function(data){
													if(data['status']){
														window.top.art.dialog({
															id: 'select'
														}).close()
														window.location.reload();
													}else{
														alert(data['msg']);
														return false;
													}
												}
											})
										}else{
											return true;
										}

									},
									function() {
										window.top.art.dialog({
											id: 'select'
										}).close()
									});
							}
						</script>


						<div class="explain-col">
							人才类型：
							<?php echo form::select($types, $_GET['talent_type'], 'name="talent_type"', '请选择')?>
							真实姓名：<input name="name" type="text" value="<?php echo $_GET['name']?>" class="input-text" />
							<input type="submit" name="search" class="button" value="<?php echo L('search');?>" />
						</div>
					</td>
				</tr>
				</tbody>
			</table>
		</form>
	</div>

	<form name="myform" id="myform" action="" method="post" >
		<div class="table-list">
			<table width="100%">
				<thead>
				<tr>
					<th width="16"><input type="checkbox" value="" id="check_box" onclick="selectall('id[]');"></th>
					<th width="57"><?php echo L('listorder');?></th>
					<th width="40">ID</th>
					<th>真实姓名</th>
					<th>英文名</th>
					<th>性别</th>
					<th>人物方形图</th>
					<th>是否置顶</th>
					<th width="200"><?php echo L('operations_manage');?></th>
				</tr>
				</thead>
				<tbody>
				<?php
				if(!empty($talentinfo)) {

					foreach ($talentinfo as $k=> $r) {
						?>
						<tr>
							<td align="center"><input class="inputcheckbox " name="id[]" value="<?php echo $r['cid'];?>" type="checkbox"></td>
							<td align='center'><input name='listorders[<?php echo $r['cid'];?>]' type='text' size='3' value='<?php echo $r['sort'];?>' class='input-text-c'></td>
							<td align='center' ><?php echo $r['id'];?></td>
							<td align='center' ><?php echo $r['real_name'];?></td>
							<td align='center' ><?php if(!empty($r['en_name'])){echo $r['en_name'];}else{echo '<font color="red">（未设置）</font>';}?></td>
							<td align='center'><?php if($r['gender'] == '1'){echo '男';}elseif($r['gender'] == '2'){echo '女';}elseif($r['gender'] == '3'){echo '保密';}?></td>
							<td align='center'><?php if(!empty($r['image'])){echo '<img src="'.$r['image'].'" height="60px">';}elseif($r['image_square']){echo '<img src="'.$r['image_square'].'" height="60px">';}else{echo '<font color="red">（未设置）</font>';}?></td>
							<td align='center' ><a href="javascript:void(0)" data-id="<?=$r['cid']?>" data-top="<?=$r['is_top']?>" onclick="changeTop(this)"><?php if($r['is_top']==1){echo "是";}else{echo "否";} ;?></a></td>
							<td align='center'><a href="javascript:edit('<?php echo $r['id']?>','<?php echo addslashes($r['real_name']);?>')"><?php echo L('edit');?> | <a href="?m=information&c=talent&a=delete&talent=1&id=<?php echo $r['cid']?>" onClick="return confirm('<?php echo L('confirm', array('message' => new_addslashes($r['real_name'])))?>')"><?php echo L('deletebind')?></a> | 
							<a href="javascript:;"
			onclick="edit1(<?php echo $r['cid']?>, '<?php echo $r['real_name'];?>')"
			title="<?php echo L('edit')?>">修改图片</a></td>

						</tr>
					<?php }
				} else {
					echo "<tr><td colspan='8' style='color:red;font-size:18px;text-align:center;'><span>暂无数据！</span></td></tr>";
				}
				?>
				</tbody>
			</table>
			<div class="btn"><label for="check_box"><?php echo L('selected_all');?>/<?php echo L('cancel');?></label>
				<input type="hidden" value="<?php echo $pc_hash;?>" name="pc_hash">
				<input type="button" class="button" value="<?php echo L('listorder');?>" onclick="myform.action='?m=information&c=talent&a=listorder&dosubmit=1&talent=1&steps=<?php echo $steps;?>';myform.submit();"/>
				<input type="button" class="button" value="<?php echo L('deletebind');?>" onclick="myform.action='?m=information&c=talent&a=delete&dosubmit=1&talent=1&steps=<?php echo $steps;?>';return confirm_delete()"/>
			</div>
			<div id="pages"><?php echo $pages;?></div>
		</div>
	</form>
</div>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>cookie.js"></script>
<script type="text/javascript">
	function confirm_delete(){
		if(confirm('<?php echo L('confirm_delete', array('message' => L('selected')));?>')) $('#myform').submit();
	}

	function edit1(id, name) {
	window.top.art.dialog({id:'edit'}).close();
	window.top.art.dialog({title:'<?php echo L('edit')?> '+name+' ',id:'edit',iframe:'?m=admin&c=resources&a=editimage&id='+id,width:'700',height:'150'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
	}

	function changeTop(obj){
		var id=$(obj).attr("data-id");
		var top=$(obj).attr("data-top");
		//top为现在状态
		var msg="";
		if(top==1){
			top=0;
			msg="否";

		}else{
			top=1;
			msg="是";
		}

		$.ajax({
			type:"get",
			url:"?m=admin&c=resources&a=top&id="+id+"&is_top="+top+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
			dataType: "json",
			success:function(data){
				if(data['status']){
						$(obj).text(msg);
					    $(obj).attr("data-top",top);
				}else{
					alert(data['msg']);
					return false;
				}
			}
		})
	}
</script>
</body>
</html>